<?php
    session_start();
    include "./config.php";    
    $_SESSION['UserName'] = $_POST['username'];
    $_SESSION['PassWord'] = $_POST['password'];
    $_SESSION['loginstat'] = 0;
    $username = $_POST['username'];
    $password = $_POST['password'];
    mysql_select_db($main_db,$conn) or die ("Can not connect DataBase:".mysql_error());
    if(!$username || !$password)
    {
        echo "Please Input your UserName and PassWord";
    }
    else
    {
        $result = mysql_query("select * from userinfo where username='$username'",$conn);
        $row =  mysql_fetch_array($result);
        if($password == $row[1])
        {
            $_SESSION['loginstat'] = 1;
			echo "<script>alert('Login Success');location='Showbook.php?username=$username';</script>";

        }
        else
        {
            echo "Wrong Username or Password try again";
        }

    }

?>
